<!DOCTYPE html>
<html lang="en">
<head>

[#include "/customer/include/static.htm"]
    <link href="${path}/resources/css/register.css?v=1.0" rel="stylesheet" type="text/css">
    <link href="${path}/resources/plug/layui/css/layui.css" rel="stylesheet" type="text/css"/>
    <script src="${path}/resources/plug/layui/layui.js" type="text/javascript"></script>
    <script src="${path}/resources/plug/layer/layer.js" type=text/javascript></script>
    <link href="${path}/resources/plug/layer/skin/default/layer.css" rel="stylesheet" type="text/css"/>
</head>
[#include "/customer/include/header.ftl"]
<div class="reg" style="margin-top: 20px">

    <h3 class="reg_tt2">
    </h3>
    <div id="regbmg">
        <form class="layui-form">
            <div class="layui-form-item" style="margin-top: 50px">
                <label class="layui-form-label">手机</label>
                <div class="layui-input-inline">
                    <input placeholder="请输入手机号码" type="text" id="mobile"  value="${phone}" name="mobile" disabled class="layui-input" lay-verify="required" onkeyup="value=value.replace(/[^\d.]/g,'')">
                </div>
                <div class="layui-input-inline">
                    <input style="width:120px;" type="button"  id="code_img" value="免费获取验证码" class="btn btn-primary sms-btn" onclick="smscode();">
                </div>

            </div>
            <div class="layui-form-item" >
                <label class="layui-form-label">验证码</label>
                <div class="layui-input-inline">
                    <input  style="background-position: 0 -630px;"  id="mobilecode" name="mobileCode"
                           lay-verify="required" type="text" placeholder="请输入手机验证码" class="layui-input">
                </div>
            </div>


            <div class="layui-form-item">
                <button lay-submit lay-filter="MainForm" class="layui-btn" style="background-color: #ff5e69;margin-left:120px;width: 280px;margin-top:3px;">确认</button>
            </div>

        </form>

    </div>
</div>
<script type="text/javascript">
    //获取验证码
    function smscode() {
        var mobile = $("#mobile").val();
        var captcha = $("#captcha").val();
        if (captcha == '') {
            layer.msg("请输入验证码");
            return;
        }
        $(".sms-btn").attr("disabled", "disabled").addClass("sel");
        $.ajax({
            type: "post",
            url: "/step_2_regcode",
            data: {
                "mobile": mobile,
                "captcha": captcha
            },
            dataType: "json",
            success: function (result) {
                layer.msg(result.content);
                if (result.type == "success") {

                    var s = 60;
                    $(".sms-btn").val(s + "秒");
                    inter = setInterval(function () {
                        s--;

                       // Cookie.set("sms-time",s);


                        $(".sms-btn").val(s + "秒");
                        if (s == 0) {
                            $(".sms-btn").removeAttr("disabled").removeClass("sel").val("获取验证码");
                            clearInterval(inter);
                        }
                    }, 1000);
                }

            },error: function (result){
                $(".sms-btn").removeAttr("disabled").removeClass("sel").val("获取验证码");
            }
        });
    }

</script>

<script>
    layui.use(['form','layer'], function(){
        var form = layui.form(), $=layui.jquery, layer = layui.layer;
        form.on('submit(MainForm)', function(data){

            var index = layer.load();
            ajax({
                url:"${path}/register_confirm",
                data: data.field,
                type:"POST",
                dataType:"json",
                success: function(result){
                    if(result.type == "success"){
                        window.location.href = "${path}/member/";
                    }else{
                        layer.msg(result.content);
                    }
                    layer.close(index);
                },
                complete:function(){
                    layer.close(index);
                }
            });
            return false;
        });
    });

</script>

[#include "/customer/include/footer.ftl"]

    </body>
</html>